from __future__ import annotations
from abc import ABC, abstractmethod
from typing import List


class Subject(ABC):
    @abstractmethod
    def register_observer(self, o: Observer):
        ...

    @abstractmethod
    def remove_observer(self, o: Observer):
        ...

    @abstractmethod
    def notify_observers(self):
        ...


class Observer(ABC):
    @abstractmethod
    def update(self, value: int):
        ...


class SimpleSubject(Subject):
    def register_observer(self, o: Observer):
        self._observers.append(o)

    def remove_observer(self, o: Observer):
        self._observers.remove(o)

    def notify_observers(self):
        for i in self._observers:
            i.update(self._value)

    def __init__(self):
        self._observers: List[Observer] = []
        self._value: int = 0

    def set_value(self, value: int):
        self._value = value
        self.notify_observers()


class SimpleObserver(Observer):
    def update(self, value: int):
        self._value = value
        self.display()

    def __init__(self, subject: Subject):
        self._value: int = 0
        self._simple_subject: Subject = subject
        subject.register_observer(self)

    def display(self):
        print(f"Value: {self._value}")


if __name__ == '__main__':
    simple_subject = SimpleSubject()
    simple_observer = SimpleObserver(simple_subject)
    simple_subject.set_value(80)
    simple_subject.remove_observer(simple_observer)
